<!doctype html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-touch-fullscreen" content="yes">
    <title>Demo - DPL Tabs</title>
    <link href="../../../css/assets/dpl/base.css" rel="stylesheet"/>
    <link href="../../../css/demo/dpl/assets/docs.css" rel="stylesheet"/>
    <link href="../../../button/assets/dpl.css" rel="stylesheet"/>
    <link href="../../../toolbar/assets/dpl.css" rel="stylesheet"/>
    <link href="../../assets/dpl.css" rel="stylesheet"/>
</head>
<body>

<div class="container">

    <h1>lazy-render Tabs - click</h1>

    <div id="tabs">


    </div>


    <p>

        <button id="add">add</button>
        <button id="add-select">add&select</button>
    </p>

</div>
<script src="/kissy/build/seed-debug.js"></script>
<script src="/kissy/src/package.js"></script>
<script>
    KISSY.use("tabs,node", function (S, Tabs,$) {
        window.tabs = new Tabs({
            render: "#tabs",
            lazyRender: true,
            items: [
                {
                    title: 'tab-1',
                    selected: true,
                    content: '<p>panel-1</p>'
                },
                {
                    title: 'tab-2',
                    content: '<p>panel-2</p>'
                }
            ],
            listeners: {
                afterRenderUI: function (e) {
                    if (e.target.isTabsPanel) {
                        S.log(e.target.get('content'));
                    }
                }
            }
        }).render();
        var index = 2;
        $('#add').on('click', function () {
            ++index;
            tabs.addItem({
                title: 'tab-' + index,
                content: '<p>panel-' + index + '</p>'
            });
        });
        $('#add-select').on('click', function () {
            ++index;
            tabs.addItem({
                title: 'tab-' + index,
                selected: true,
                content: '<p>panel-' + index + '</p>'
            });
        });


    });
</script>
</body>
</html>